package com.presto.directo.utils

import java.text.SimpleDateFormat
import java.util.*

fun Long.formatTime(format: String = "dd MMMM yyyy"): String {
    if (this == Long.MAX_VALUE) {
        return ""
    }
    return try {
        SimpleDateFormat(format, Locale("es")).format(this)
    } catch (e: Exception) {
        ""
    }
}

fun String.formatTime(format: String = "dd MMMM yyyy"): String {
    return try {
        SimpleDateFormat(format, Locale("es")).format(toLong())
    } catch (e: Exception) {
        ""
    }
}

fun String.parseTime(format: String = "dd MMMM yyyy"): Long {
    return try {
        SimpleDateFormat(format, Locale("es")).parse(this).time
    } catch (e: Exception) {
        Long.MAX_VALUE
    }
}
